<script setup>
import { Plus } from "@element-plus/icons-vue";
import useTable from "@/utils/useTable";
import {http} from "@/api";
import { ref } from "vue";
import UploadImage from "@/components/UploadImage.vue";

/**
 * 表格
 * @type {Ref<UnwrapRef<*[]>>}
 */
const {
  searchParams,
  pageNo,
  pageSize,
  total,
  changePage,
  changeSize,
  dataSource,
  search,
  reset,
  openDelete
} = useTable({
  requestFn: http.user,
  params: {
    nickname: '',
    type: 1
  }
})
const dialog = ref(false)
const formModel= ref({})
const openEdit = (row) => {
  dialog.value = true
  formModel.value = {...row}
}
</script>


<template>
  <el-dialog
      v-model="dialog"
      title="律师信息"
      width="500px"
  >
    <el-form :model="formModel" ref="formRef" label-position="top" disabled>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="头像" style="width: 100%" prop="">
            <UploadImage v-model:image="formModel.image" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="昵称" prop="nickname">
            <el-input clearab v-model="formModel.nickname" placeholder="请输入昵称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="电话" prop="phone">
            <el-input clearab v-model="formModel.phone" placeholder="请输入电话"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
          <span class="dialog-footer">
            <el-button @click="dialog = false">取消</el-button>
          </span>
    </template>
  </el-dialog>

  <PageMain title="律师咨询">
    <el-form label-suffix="：" inline>
      <el-form-item label="名称">
        <el-input v-model="searchParams.nickname" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">查询</el-button>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="table-box">
      <el-table :data="dataSource">
        <el-table-column label="名称" prop="nickname">
        </el-table-column>
        <el-table-column label="头像">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <ViewImage type="image" :image-url="scope.row.image"/>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button type="text" @click="openEdit(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          v-model:current-page="pageNo"
          v-model:page-size="pageSize"
          :page-sizes="[10, 50, 100, 200]"
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="changeSize"
          @current-change="changePage"
      />
    </div>
  </PageMain>
</template>

<style scoped lang="scss">

</style>
